package mas;

/** Class represents a message to be used for communication between MetaAgents 
 * and their various extensions 
 * 
 * Advanced Java Programming - ICA 2 Middleware 
 * @author Carl Morphet, Matt Constable, Stephen Pammenter
 * Teesside University
 * @version %I% 
 * Created: Apr 12, 2012
 */
public class Message 
{
    /** The messages identifier */
    private String id;
    
    /** The identifier of the messages sender */
    private String sender;
    
    /** The identifier of the messages recipient */
    private String recipient;
    
    /** The content of the message */
    private String messageContent;

    /** Overloaded constructor which sets up the messages various instance
     * variables 
     * 
     * @param id The messages identifier 
     * @param from The sending Agents identifier
     * @param to The receiving Agents identifier
     * @param message The messages content
     */
    public Message(String id, String from, String to, String message)
    {
        this.id = id;
        this.sender = from;
        this.recipient = to;
        this.messageContent = message;
    }

    /** Accessor method which returns the sending Agents identifier
     *  
     * @return The sending agents identifier
     */
    protected String getSender()
    {
        return sender;
    }
    
    /** Accessor method which returns the intended recipient Agents identifier
     * 
     * @return The recipient Agents identifier
     */
    protected String getRecipient()
    {
        return recipient;
    }
    
    /** Accessor method which returns the Message objects message 
     * 
     * @return The message content of the Message
     */
    protected String getMessage()
    {
        return messageContent;
    }
    
    /** Accessor method which returns the Message objects identifier
     * 
     * @return The Message objects identifier
     */
    protected String getID()
    {
        return id;
    }
    
    /** An overriding of the toString() method which returns the messages 
     * identifier 
     * 
     * @return The message objects identifier 
     */
    @Override
    public String toString()
    {
        return id + " " + sender + " " + recipient + " " + messageContent;
    }
}